<?php

// phpMyRealty 3
//
// File Name: searchFormMain.php
// File Location : ./templates/default/
//
// Copyright (c)2009 phpMyRealty.com
//
// e-mail: support@phpMyRealty.com

?>
<!-- Simple search form Horizontal : start -->

     <div id="tab-search" class="tabcontent">
    
      <form action="<?php echo URL ?>/search.php" method="POST">

      <table cellspacing="0"  cellpadding="3" border="0" width="100%">
       <tr>
        <td width="33%" align="left" valign="top" style="border-right : 1px dotted #DADADA;" >

         <h2><?php echo $lang['WHAT']; ?>:</h2>

<?php 
 	 if (strcasecmp($conf['show_mls'], 'OFF') != 0) {
 	      echo $lang['Listing_MLS'] . '<br />
	 <input type="text" name="mls" size="20" />
	 <br /><br />';
 	  }
?>

 	 <?php echo $lang['Listing_Title'] . '<br />'; ?>
	 <input type="text" name="title" size="20">

	<br /><br />

 	 <?php echo $lang['Module_Listing_Type'] . '<br />'; ?>
         <select name="type2">
	  <option value="ANY" class="price_range_any"><?php echo $lang['Search_Any'] . ' ' . $lang['Module_Listing_Type'];?></option>
	  <?php echo generate_options_list ( TYPES2_TABLE, '', 'price_range_' )?>
         </select>

	<br /><br />

 	 <?php echo $lang['Listing_Property_Type'] . '<br />'; ?>
 	 <div id="typesdiv" name="typesdiv">
         <select name="type">
	  <option value="ANY"><?php echo $lang['Search_Any'] . ' ' . $lang['Listing_Property_Type'];?></option>
	  <?php echo generate_options_list ( TYPES_TABLE )?>
         </select>
         </div>

        </td>
        <td width="33%" align="left" valign="top"  style="border-right : 1px dotted #DADADA;">

	<h2><?php echo $lang['WHERE']; ?>:</h2>

	<?php echo $lang['Location'] ?> <br />

          <select name="location1" class="span3" id="location1" onchange="xajax_fetchLocations2(this.value);">

<?php

    $r_location1 = $db->query('SELECT selector, category FROM ' . LOCATION1_TABLE . ' ORDER BY category ASC');

    $newContentMain = '<option value="ANY">' . $lang['Select'] . '</option>' . "\n";
   
    while ($f_location1 = $db->fetcharray($r_location1)) {
     $newContentMain.= '<option value="' . $f_location1['selector'] . '">' . $f_location1['category'] . '</option>' . "/n";
    }

    echo $newContentMain;

?>
          </select>
          <div style="display: inline" id="location2div" name="location2div"></div>
          <div style="display: inline" id="location3div" name="location3div"></div>

 	 <br /><br />

	 <?php echo $lang['Realtor_Address'] . '<br />'; ?>
	 <input type="text" name="address" size="20">

 	 <br /><br />

<?php 
  if (strcasecmp(@$conf['show_postal_code'], 'OFF') != 0) {
	 echo $lang['Zip_Code'] . '<br />
	 <input type="text" name="zip" size="20" />
	 <br /><br />';
  }
?>

	 <input type="checkbox" name="image_uploaded" value="1">
	 <?php echo $lang['Search_Images_Only']; ?>

        </td>
        <td width="33%" align="left" valign="top" >

<h2><?php echo $lang['OPTIONS']; ?>:</h2>

    <div id="search_price">

        <?php echo $lang['Search_Price_Range']; ?><br />
        <?php
         $price_ranges = array();
         $price_ranges['monthly'] = array();
         for ($i = $conf['price_monthly_range_min']; $i <= $conf['price_monthly_range_max']; $i = $i + $conf['price_monthly_range_step']) {
             $price_ranges['monthly'][] = $i;
         }
         $price_ranges['sale'] = array();
         for ($i = $conf['price_range_min']; $i <= $conf['price_range_max']; $i = $i + $conf['price_range_step']) {
             $price_ranges['sale'][] = $i;
         }
         $price_ranges['any'] = array_unique(array_merge($price_ranges['monthly'], $price_ranges['sale']));
         sort($price_ranges['any']);
         
         foreach ($price_ranges as $_range => $_prices) {
             switch ($_range) {
             case 'any':
                 $_style = '';
                 break;
             default:
                 $_style = ' style="display: none;"';
                 break;
             }
?>
        <table id="price_range_<?php echo $_range; ?>" <?php echo $_style; ?>class="price_range" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
         <select name="price_min_<?php echo $_range; ?>">
      <option value="ANY"><?php echo $lang['Search_Any'];?></option>
<?php
             $price_range = '';
             foreach ($_prices as $i) {
                $selected = ($i == $search['price_min']) ? ' selected="selected"' : '';
                $price_range.= '<option value="' . $i . '"'.$selected.'>' . $conf['currency'] . ' ' . number_format($i) . '</option>' . "\n";
             }
        
             echo $price_range;
?>
         </select><br />
	 <?php echo $lang['Search_To']; ?><br />
         <select name="price_max_<?php echo $_range; ?>">
      <option value="ANY"><?php echo $lang['Search_Any'];?></option>
<?php
             $price_range = '';
             foreach ($_prices as $i) {
                 $selected = ($i == $search['price_max']) ? ' selected="selected"' : '';
                 $price_range.= '<option value="' . $i . '"'.$selected.'>' . $conf['currency'] . ' ' . number_format($i) . '</option>' . "\n";
             }
             echo $price_range; 
?>
         </select>
         </td></tr>
    </table>
<?php 
         }
?>

<script type="text/javascript">
(function($){
    $(document).ready(function() {
        $(":select[name=type2]").change(function() {
            var c = $(":select[name=type2] option:selected").attr("class");
            $(".price_range").hide();
            $("#" + c).show();
        });
        $(":select[name=type2]").change();
    });
})(jQuery);
</script>

    </div>
<br />
         <table cellpadding="0" cellspacing="0" border="0">
          <tr>
           <td width="50%" align="left">
  	    <?php echo $lang['Listing_Bedrooms'] . '<br />'; ?>

		<select name="bedrooms">
		 <option value="ANY"><?php echo $lang['Search_Any'];?></option>
		 <option value="1">1+</option>
		 <option value="2">2+</option>
		 <option value="3">3+</option>
		 <option value="4">4+</option>
		 <option value="5">5+</option>
		 <option value="6">6+</option>
		 <option value="7">7+</option>
		 <option value="8">8+</option>
		 <option value="9">9+</option>
		 <option value="10">10+</option>
		</select>

	   </td>
           <td width="50%" align="left">
  	    <?php echo $lang['Listing_Bathrooms'] . '<br />'; ?>

		<select name="bathrooms">
		 <option value="ANY"><?php echo $lang['Search_Any'];?></option>
		 <option value="1">1+</option>
		 <option value="2">2+</option>
		 <option value="3">3+</option>
		 <option value="4">4+</option>
		 <option value="5">5+</option>
		 <option value="6">6+</option>
		 <option value="7">7+</option>
		 <option value="8">8+</option>
		 <option value="9">9+</option>
		 <option value="10">10+</option>
		</select>

	   </td>
	  </table>

	 <br />
         <input type="submit" name="property_search" class="submit" value="<?php echo $lang['Search']; ?>">

         <?php    if ($conf['rewrite'] == 'ON')    { 
          echo '<a href="' . URL . '/search.html">' . $lang['Advanced_Search'] . '</a>';
         }   else  { 
          echo '<a href="' . URL . '/advsearchform.php">' . $lang['Advanced_Search'] . '</a>';
         } ?>

        </td>
       </tr>
      </table>

	    <input type="hidden" name="seed" value="<?php echo rand(1,1000); ?>">

     </form>

    </div>

<!-- Simple search form Horizontal : stop -->